// Copyright (c) 2018 Muhammad M. Imtiaz

// This Work is subject to the terms of the Universal Permissive License,
// Version 1.0. If a copy of the licence was not distributed with this Work,
// you can obtain one at <https://oss.oracle.com/licenses/upl/>.

public class TargetZone {
    public static void main(String[] args) {
	int age,
	    restingHeartRate,
	    heartRateAfterExercising,
	    maxHeartRate,
	    minTargetHeartRate,
	    maxTargetHeartRate,
	    heartRateReserve;
	java.util.Scanner input = new java.util.Scanner(System.in);

	System.out.print("Enter your age: ");
	age = input.nextInt();
	System.out.print("Enter your resting heart rate: ");
	restingHeartRate = input.nextInt();
	System.out.print("Enter your heart rate after exercising: ");
	heartRateAfterExercising = input.nextInt();

	maxHeartRate = 220 - age;
	heartRateReserve = maxHeartRate - restingHeartRate;

	maxTargetHeartRate = (int)(0.85 * heartRateReserve) + restingHeartRate;
	minTargetHeartRate = (int)(0.5 * heartRateReserve) + restingHeartRate;

	System.out.println("Your target heart rate zone is between " + minTargetHeartRate + " and " + maxTargetHeartRate);
	System.out.print("After just exercising, your heart rate is ");

	if(minTargetHeartRate > heartRateAfterExercising || maxTargetHeartRate < heartRateAfterExercising)
	    System.out.print("*NOT* ");

	System.out.println("within your target zone.");
    }
}
